# encoding: utf-8
# @File  : page_login.py
# @Author: wu shaofan
# @Date  :  2024/04/17
# @Desc : 登录页面
from selenium.webdriver.common.by import By
from PO.base.base import Base


class PageLogin(Base):
    # 用户名输入框
    login_username = By.ID, "username"
    # 密码输入框
    login_password = By.ID, "password"
    # 验证码输入框
    login_verify_code = By.ID, "verify_code"
    # 点击登录按钮
    login_btn = By.CSS_SELECTOR, ".J-login-submit"
    # 点击登录后，页面弹框提示信息
    login_alert_info = By.CSS_SELECTOR, ".layui-layer-content.layui-layer-padding"
    # 点击弹框的确认按钮
    login_alert_confirm_btn = By.LINK_TEXT, "确定"

    # 输入用户名
    def page_input_username(self, username):
        self.base_input(self.login_username, username)
        self.base_get_allure_image()

    # 输入密码
    def page_input_password(self, pwd):
        self.base_input(self.login_password, pwd)
        self.base_get_allure_image()

    # 输入验证码
    def page_input_verify_code(self, code):
        self.base_input(self.login_verify_code, code)
        self.base_get_allure_image()

    # 点击登录按钮
    def page_click_login_btn(self):
        self.base_click(self.login_btn)
        self.base_get_allure_image()

    # 登录用户
    def login_user(self):
        self.page_input_username("18325530001")
        self.page_input_password("wsf123456")
        self.page_input_verify_code("8888")
        self.page_click_login_btn()

    # 获取登录后弹框信息
    def page_get_login_alert_info(self):
        return self.base_get_text(self.login_alert_info)

    # 点击登录后弹框的确定按钮
    def page_click_login_alert_confirm_btn(self):
        self.base_click(self.login_alert_confirm_btn)
        self.base_get_allure_image()
